import java.util.*;

public class StackToQueue {
    private Stack<Integer> stack1;
    private Stack<Integer> stack2;

    public StackToQueue() {
        stack1 = new Stack<>();
        stack2 = new Stack<>();
    }

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        if(empty()) return -1;
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                int t = stack1.pop();
                stack2.push(t);
            }
        }
        int ret = stack2.pop();
        return ret;
    }

    public int peek() {
        if(empty()) return -1;
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                int t = stack1.pop();
                stack2.push(t);
            }
        }
        int ret = stack2.peek();
        return ret;
    }

    public boolean empty() {
        if(stack1.isEmpty() && stack2.isEmpty()){
            return true;
        }
        return false;
    }
}
